import sys
import os
import random
import time
import cProfile

project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
# 将项目根目录加入到搜索路径中
sys.path.append(project_root)
from pms_simulator import Parser,Subject,Desimulator,DataProcess


def main(argv=None):
    random.seed(758)
    dict={}
    dict['simulate_times']=500
    dict['timeslice'] = 1.0/6

    dict['result_home']='D:\\'


    parser = Parser('./benchmarks/bugs/model.xml')
    pms_model = parser.parse_xml_ET()
    subject = Subject()
    time_start = time.time()
    solver = Desimulator(parser.get_xml_str(),subject,dict['simulate_times'],dict['timeslice'])
    results,results2 = solver.run('0001')
    time_end = time.time()
    print('运行时间：',time_end-time_start,'s')
    dp = DataProcess(subject,'0001',dict['result_home'])
    dp.str2xml(pms_model,dict['timeslice'],dict['simulate_times'],results,results2)

main()
print('仿真结束')